# Contributor: Holger Jaekel <holger.jaekel@gmx.de>
# Maintainer: Holger Jaekel <holger.jaekel@gmx.de>
pkgname=lerc
pkgver=4.0.0
pkgrel=0
pkgdesc="Limited Error Raster Compression"
url="https://github.com/esri/lerc"
arch="all !s390x"  # tests fail on s390x
license="Apache-2.0"
makedepends="cmake samurai"
subpackages="$pkgname-dev"
source="lerc-$pkgver.tar.gz::https://github.com/Esri/lerc/archive/refs/tags/v$pkgver.tar.gz"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=/usr/lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		$CMAKE_CROSSOPTS
	cmake --build build -v

	g++ $CXXFLAGS -L$builddir/build src/LercTest/main.cpp -o src/LercTest/main -lLerc
}

check() {
	# Test program ends with "press ENTER"
	echo "\n" | LD_LIBRARY_PATH="$builddir"/build src/LercTest/main
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
36fe453b6e732f6bed554d1c1c5cd4668aec63593d6de11f12b659c7b9cbc059ac9aaacc6cea483b3257d522f1b07e13c299914d08b1f8aeb0bb2cde42ba47cf  lerc-4.0.0.tar.gz
"
